<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>while do..while 验证用户名和密码</title>
</head>
<body>
<script>
  var username = prompt("请输入用户名:");
  var password = prompt("请输入密码:");

  while (username !== "admin" || password !== "123456") {
    alert("用户名或密码有误，请重新输入！");
    username = prompt("请输入用户名:");
    password = prompt("请输入密码:");
  }
  alert("登录成功！");
  /* var username, password;

        do {
            username = prompt("请输入用户名:");
            password = prompt("请输入密码:");

            if (username !== "admin" || password !== "123456") {
                alert("用户名或密码有误，请重新输入！");
            }
        } while (username !== "admin" || password !== "123456");

        alert("登录成功！");*/
</script>
</body>
</html>
